//
//  ViewController.m
//  11-5
//
//  Created by mac on 15-11-5.
//  Copyright (c) 2015年 cjz. All rights reserved.
//

#import "ViewController.h"

@interface ViewController (){
    UILabel *l;}

@end

@implementation ViewController

- (void)viewDidLoad;
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.view.backgroundColor=[UIColor redColor];
    l=[UILabel new];
    l.text=@"你好,世界!";
    [l sizeToFit];
    l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
    l.textColor = [UIColor grayColor];
    [self.view addSubview:l];
    
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame= CGRectMake(100, 100, 200, 44);
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
//    [btn setTitle:@"你按下了" forState:UIControlStateSelected];
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchDragInside];
    [self.view addSubview:btn];
    
}

- (void)onClick:(id)sender{
    [UIView animateWithDuration:1.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0 , 44);}];}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    [UIView animateWithDuration:8.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height - 100);}];}

@end
